package com.geek.javase.ch07.strings;

import java.util.Arrays;

/*
 *@author wangpeng
 *2025/10/15 16:04
 *@description TODO
 */
//2.给定一个字符串数组。按照字典顺序进行从小到大的排序。{"nba","abc","cba","zz","qq","haha"}
/*方式一：数组中元素，自身具备比较性
String implements Comparable<String>接口，重写了compareTo(o)
Arrays.sort(arr)

方式二：容器具备比较性  传入Comparator比较器
Arrays.sort(arr , new Comparator<String>(){ ... })*/
public class StringBuilderDemo2 {
    public static void main(String[] args) {
        String[] arr = {"nba","abc","cba","zz","qq","haha"};
        Arrays.sort(arr);
        for(String s : arr){
            System.out.println(s);
        }
    }
}
